package com.appwoo.txtws.service;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.bean.SeniorListBean;
import com.appwoo.txtws.bean.TimeConfigBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.Logger;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

public class RQUrlPeroid
{
  SharedPreferences.Editor editor;
  String nowTime;
  SharedPreferences.Editor spEditor;
  String times;
  String todayRule;
  SharedPreferences waySP;
  SharedPreferences webControlSP;

  private void bgRQTimeConfig(Context paramContext)
  {
    String str = Global.getIMEI(paramContext);
    if (str != null);
    try
    {
      TimeConfigBean localTimeConfigBean = new TimerService().RQTimeConfig(Global.USERNAME, str, paramContext);
      if (localTimeConfigBean != null)
      {
        dealWithTimeConfig(localTimeConfigBean.getTimeLength(), localTimeConfigBean.getTimeType(), paramContext);
        bgRQWay(localTimeConfigBean.getCmdType(), paramContext);
        bgRQUnlimits(localTimeConfigBean.getUnlimited(), paramContext);
      }
      return;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
      return;
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      localXmlPullParserException.printStackTrace();
      return;
    }
    catch (TimeOutException localTimeOutException)
    {
      localTimeOutException.printStackTrace();
      return;
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.printStackTrace();
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private void bgRQUnlimits(String paramString, Context paramContext)
  {
    SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("ScreenLock", 0);
    int i = localSharedPreferences.getInt("unlimit", 0);
    try
    {
      int j = Integer.parseInt(paramString);
      i = j;
      label29: if (Global.unLimit != i)
      {
        Global.unLimit = i;
        SharedPreferences.Editor localEditor = localSharedPreferences.edit();
        localEditor.putInt("unlimit", i);
        localEditor.commit();
        Global.unLimitChange = true;
        WebTimeControlService.ut = 0L;
      }
      return;
    }
    catch (Exception localException)
    {
      break label29;
    }
  }

  private void bgRQWay(String paramString, Context paramContext)
  {
    SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("ScreenLock", 0);
    Global.way = localSharedPreferences.getInt("hway", 1);
    try
    {
      int j = Integer.parseInt(paramString);
      i = j;
      if (Global.way != i)
      {
        if ("0".equals(paramString))
        {
          Global.way = 0;
          SharedPreferences.Editor localEditor = localSharedPreferences.edit();
          localEditor.putInt("hway", i);
          localEditor.commit();
          Global.wayChange = true;
          WebTimeControlService.ut = 0L;
        }
      }
      else
        return;
    }
    catch (Exception localException)
    {
      while (true)
      {
        int i = 2;
        continue;
        if ("1".equals(paramString))
          Global.way = 1;
        else if ("2".equals(paramString))
          Global.way = 2;
        else
          Global.way = 2;
      }
    }
  }

  public static void bgRQWay1(String paramString, Context paramContext)
  {
    SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("ScreenLock", 0);
    Global.way1 = localSharedPreferences.getInt("sway", 1);
    try
    {
      int j = Integer.parseInt(paramString);
      i = j;
      if (Global.way1 != i)
      {
        if ("0".equals(paramString))
        {
          Global.way1 = 0;
          SharedPreferences.Editor localEditor = localSharedPreferences.edit();
          localEditor.putInt("sway", i);
          localEditor.commit();
          Global.wayChange = true;
          WebTimeControlService.ut = 0L;
        }
      }
      else
        return;
    }
    catch (Exception localException)
    {
      while (true)
      {
        int i = 1;
        continue;
        if ("1".equals(paramString))
          Global.way1 = 1;
        else if ("2".equals(paramString))
          Global.way1 = 2;
        else
          Global.way1 = 2;
      }
    }
  }

  private void dealWithTimeConfig(String paramString1, String paramString2, Context paramContext)
  {
    if (paramString2.equals("0"))
    {
      udSumTime(true, paramContext);
      udTimeStep(false, paramContext);
      udTimeSenior(false, paramContext);
    }
    while (true)
    {
      saveTimeLength(paramString1, paramContext);
      return;
      if (paramString2.equals("1"))
      {
        udSumTime(false, paramContext);
        udTimeStep(true, paramContext);
        udTimeSenior(false, paramContext);
      }
      else if (paramString2.equals("2"))
      {
        udSumTime(false, paramContext);
        udTimeStep(false, paramContext);
        udTimeSenior(true, paramContext);
      }
      else if (paramString2.equals("3"))
      {
        udSumTime(true, paramContext);
        udTimeStep(true, paramContext);
        udTimeSenior(false, paramContext);
      }
      else if (paramString2.equals("4"))
      {
        udSumTime(true, paramContext);
        udTimeStep(false, paramContext);
        udTimeSenior(true, paramContext);
      }
      else if (paramString2.equals("-1"))
      {
        udSumTime(false, paramContext);
        udTimeStep(false, paramContext);
        udTimeSenior(false, paramContext);
      }
    }
  }

  private String[] dealWithWeek(String paramString)
  {
    String[] arrayOfString1 = (String[])null;
    try
    {
      String[] arrayOfString2 = paramString.split(",");
      return arrayOfString2;
    }
    catch (Exception localException)
    {
    }
    return arrayOfString1;
  }

  public static long getDelay(Context paramContext)
  {
    return paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0).getLong("delay", 0L);
  }

  private String quickCmd(Context paramContext, String paramString1, String paramString2)
  {
    Object localObject = "";
    try
    {
      String str1 = Global.getIMEI(paramContext);
      String str2 = new LoginService().quickSubmit(paramString1, str1, str1, paramString2, paramContext);
      localObject = str2;
      Logger.e("bod", "rqurl修改一键指令-cmd-" + paramString1 + "-返回值-code-" + (String)localObject);
      return localObject;
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        localXmlPullParserException.printStackTrace();
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        localTimeOutException.printStackTrace();
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
        localNotFoundNetWorkException.printStackTrace();
    }
  }

  public static void saveCloseTime(String paramString1, String paramString2, Context paramContext)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0).edit();
    localEditor.putString(paramString1, paramString2);
    localEditor.commit();
  }

  public static void saveOpenTime(String paramString1, String paramString2, Context paramContext)
  {
    SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0);
    SharedPreferences.Editor localEditor = localSharedPreferences.edit();
    long l = getDelay(paramContext);
    String str = localSharedPreferences.getString(paramString1, paramString2);
    Date localDate1 = Global.transDate(str.split(" ")[0]);
    Date localDate2 = Global.transDate(paramString2.split(" ")[0]);
    Date localDate3 = Global.transDateTime(str);
    Date localDate4 = Global.transDateTime(paramString2);
    if (localDate1.equals(localDate2))
      l += (localDate4.getTime() - localDate3.getTime()) / 1000L;
    while (true)
    {
      Logger.e("xjf", "closeDate:" + localDate1 + "\t openDate:" + localDate2 + "\tdelay:" + l);
      localEditor.putLong("delay", l);
      localEditor.commit();
      return;
      if (localDate2.after(localDate1))
        l += localDate4.getTime() / 1000L;
    }
  }

  private static void saveTimeLength(String paramString, Context paramContext)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0).edit();
    localEditor.putString("timelength", paramString);
    localEditor.commit();
  }

  private void udSumTime(boolean paramBoolean, Context paramContext)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0).edit();
    localEditor.putBoolean("shichang", paramBoolean);
    localEditor.commit();
  }

  private void udTimeSenior(boolean paramBoolean, Context paramContext)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0).edit();
    localEditor.putBoolean("gaoji", paramBoolean);
    localEditor.commit();
  }

  private void udTimeStep(boolean paramBoolean, Context paramContext)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("timeconfig" + Global.getTodayDate(paramContext), 0).edit();
    localEditor.putBoolean("shiduan", paramBoolean);
    localEditor.commit();
  }

  public void bgRQMode(Context paramContext)
  {
    DBHelper localDBHelper = new DBHelper(paramContext);
    String str1 = localDBHelper.getSeniorTimeMin();
    String str2 = localDBHelper.getSeniorTimeMax();
    if (str1 == null)
    {
      str1 = "08:00:00";
      str2 = "08:00:00";
      Logger.w("bod", "高级时间 最大最小 无法取到。。。");
    }
    while (true)
    {
      boolean bool;
      try
      {
        bool = checkSpecTime(paramContext, Global.isBoarding);
        Date localDate1 = Global.transTime(str1);
        Date localDate2 = Global.transTime(str2);
        Date localDate3 = Global.transTime(Global.getTodayTime(paramContext));
        Logger.d("bod", "minT1--->" + str1);
        Logger.i("bod", "Global.getTodayTime--->" + Global.getTodayTime(paramContext));
        Logger.d("bod", "maxT2--->" + str2);
        if ((localDate3.after(localDate1)) && (localDate3.before(localDate2)))
        {
          Global.mode = 1;
          Logger.i("bod", "Global.mode--->" + Global.mode + "学校模式");
          return;
          String str3 = new DBHelper(paramContext).getT2();
          new RQScreenLock(paramContext).UnlockScreenCmd(str3);
          new RQNetLock(paramContext).onNetCmd(str3);
          Global.mode = 0;
          Logger.i("bod", "Global.mode--->" + Global.mode + "家庭模式");
          return;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return;
      }
      if (!bool);
    }
  }

  public void bgRQSenior(Context paramContext, List<SeniorListBean> paramList)
  {
    DBHelper localDBHelper = new DBHelper(paramContext);
    int j;
    if (paramList != null)
    {
      int i = paramList.size();
      if (i > 0)
      {
        Global.issenTimeUpdate = true;
        j = 0;
        if (j < i)
          break label96;
        Logger.e("bod", "已更新本地-校园高级时间");
        if (Global.mode != 1)
          break label246;
      }
    }
    label96: label246: for (int k = Global.way1; ; k = Global.way)
    {
      RQScreenLock localRQScreenLock = new RQScreenLock(paramContext);
      localRQScreenLock.screenSeniorTime(k, true);
      updateCmd(paramContext, "sen");
      WebTimeControlService.ut = 0L;
      bgRQMode(paramContext);
      return;
      SeniorListBean localSeniorListBean = (SeniorListBean)paramList.get(j);
      if (localSeniorListBean != null)
      {
        String str1 = localSeniorListBean.getId();
        String str2 = localSeniorListBean.getWeek();
        String str3 = localSeniorListBean.getStartime();
        String str4 = localSeniorListBean.getEndtime();
        String str5 = localSeniorListBean.getType();
        String str6 = localSeniorListBean.getIsDel();
        String str7 = localSeniorListBean.getCmdtype();
        String str8 = localSeniorListBean.getCmdrange();
        String str9 = localSeniorListBean.getCname();
        if (((str3 != null) || (str4 != null)) && ((!str3.equals("")) || (!str4.equals("")) || (!str2.equals(""))))
          localDBHelper.updateSeniorTime(str1, str2, str3, str4, str7, str8, str5, str6, str9);
      }
      j++;
      break;
    }
  }

  public void bgRQTimePeriod(Context paramContext, String paramString)
  {
    String str1;
    int k;
    if ((paramString != null) && (!paramString.equals("")))
    {
      Global.issimTimeUpdate = true;
      str1 = paramString.replace(",", "");
      if (str1.length() < 672)
      {
        str1 = "";
        k = 0;
      }
    }
    while (true)
    {
      if (k >= 700)
      {
        this.webControlSP = paramContext.getSharedPreferences("web_time_control", 0);
        this.editor = this.webControlSP.edit();
      }
      try
      {
        String str2 = str1.substring(0, 96);
        String str3 = str1.substring(96, 192);
        String str4 = str1.substring(192, 288);
        String str5 = str1.substring(288, 384);
        String str6 = str1.substring(384, 480);
        String str7 = str1.substring(480, 576);
        String str8 = str1.substring(576, 672);
        this.editor.clear();
        this.editor.commit();
        this.editor.putString("1", str3);
        this.editor.putString("2", str4);
        this.editor.putString("3", str5);
        this.editor.putString("4", str6);
        this.editor.putString("5", str7);
        this.editor.putString("6", str8);
        this.editor.putString("0", str2);
        this.editor.commit();
        String[] arrayOfString = { str2, str3, str4, str5, str6, str7, str8 };
        DBHelper localDBHelper = new DBHelper(paramContext);
        int i = 0;
        label341: if (i >= 7)
        {
          Logger.e("bod", "已更新本地-简单时间段规则");
          if (Global.mode != 1)
            break label453;
        }
        label453: for (int j = Global.way1; ; j = Global.way)
        {
          new RQScreenLock(paramContext).screenSimpleTime(j, true);
          updateCmd(paramContext, "sim");
          WebTimeControlService.ut = 0L;
          return;
          str1 = str1 + "1";
          k++;
          break;
          localDBHelper.updatePeriod(i, arrayOfString[i]);
          i++;
          break label341;
        }
        Logger.e("bod", "无数据可，，更新本地时间段规则");
        return;
      }
      catch (Exception localException)
      {
      }
    }
  }

  public void call(Context paramContext)
  {
    bgRQTimeConfig(paramContext);
  }

  public boolean checkSpecTime(Context paramContext, String paramString)
  {
    return new DBHelper(paramContext).getSpecialTimeCount(paramString) > 0;
  }

  public void updateCmd(Context paramContext, String paramString)
  {
    SharedPreferences localSharedPreferences1 = paramContext.getSharedPreferences("ScreenLock", 0);
    SharedPreferences localSharedPreferences2 = paramContext.getSharedPreferences("NetControl", 0);
    String str1 = localSharedPreferences1.getString("ScreenCmd", "2");
    String str2 = localSharedPreferences1.getString("LockTime", "2011-11-11 11:11:11");
    String str3 = localSharedPreferences2.getString("NetCmd", "3");
    String str4 = localSharedPreferences2.getString("CutTime", "2011-11-11 11:11:11");
    Date localDate1 = Global.transDateTime(WebTimeControlService.srnLtime);
    Date localDate2 = Global.transDateTime(str2);
    Date localDate3 = Global.transDateTime(WebTimeControlService.netLtime);
    Date localDate4 = Global.transDateTime(str4);
    if (localDate1.before(localDate2))
    {
      String str6 = quickCmd(paramContext, str1, str2);
      Logger.d("bod", "rqUrlPeriod,code:" + str6 + "==rqurl发送一键[屏幕]" + str1 + "\told=" + WebTimeControlService.srnLtime + "\tnew=" + str2);
      if ("0".equals(str6))
        WebTimeControlService.srnLtime = str2;
    }
    if (localDate3.before(localDate4))
    {
      String str5 = quickCmd(paramContext, str3, str4);
      Logger.d("bod", "rqUrlPeriod,code:" + str5 + "==rqurl发送一键[网络]" + str3 + "\told=" + WebTimeControlService.netLtime + "\tnew=" + str4);
      if ("0".equals(str5))
        WebTimeControlService.netLtime = str4;
    }
    if (paramString.equals("sim"))
      Global.issimTimeUpdate = false;
    if (paramString.equals("sen"))
      Global.issenTimeUpdate = false;
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.service.RQUrlPeroid
 * JD-Core Version:    0.6.2
 */